package crp.services.api.graphql;

import crp.core.security.app.PermissionService;
import org.eclipse.microprofile.graphql.GraphQLApi;
import org.eclipse.microprofile.graphql.Query;

import javax.annotation.security.PermitAll;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.transaction.Transactional;
import javax.validation.constraints.NotNull;
import java.util.List;

@GraphQLApi
@RequestScoped
@Transactional
public class PermissionGraphQLApi {
    private final PermissionService permissionService;

    @Inject
    public PermissionGraphQLApi(PermissionService permissionService) {
        this.permissionService = permissionService;
    }

    @Query
    @PermitAll
    @NotNull
    public List<@NotNull String> permissions() {
        return permissionService.searcher().all();
    }
}
